﻿@Html.DevExpress().GridView(
            settings =>
            {
                settings.Name = "gvTaxAudit_SB_ZSXX";
                settings.KeyFieldName = "FTaxClassAllowanceNo";
                settings.CallbackRouteValues = new { Controller = "TaxAuditForm", Action = "TaxAudit_SB_ZSXXListPartial" };
                settings.Width =System.Web.UI.WebControls.Unit.Percentage(99);

                settings.Columns.Add(column =>
                {
                    column.Caption = "操作";
                    column.FieldName = "cz";
                    column.SetDataItemTemplateContent(c =>
                    {
                        if (DataBinder.Eval(c.DataItem, "cz") == "mx")
                        {
                            Html.DevExpress().HyperLink(s => { s.Name = "linkLookEntry" + c.VisibleIndex; s.Properties.Text = "查看明细"; s.ToolTip = "查看明细"; s.Properties.ImageUrl = Url.Content("~/Content/ControlImages/button_query.png"); s.Properties.ClientSideEvents.Click = "function(){look('" + DataBinder.Eval(c.DataItem, "FTaxClassAllowanceNo") + "')}"; s.Style.Add(HtmlTextWriterStyle.Cursor, "pointer"); }).GetHtml();
                        }
                        else
                        {
                            ViewContext.Writer.Write(DataBinder.Eval(c.DataItem, "cz")); 
                        }
                    });
                    column.Settings.AllowDragDrop = DefaultBoolean.False;
                    column.Settings.AllowSort = DefaultBoolean.False;
                    column.Width = 70;
                });
                 

                settings.Columns.Add("FTaxClassAllowanceName", "可补贴税种");
                settings.Columns.Add("FDataSource", "来源");
                settings.Columns.Add("se", "金额");
                settings.Columns.Add("FAdjustAmount", "调整金额");
                settings.Columns.Add("sumse", "当前金额");
                
                settings.SettingsBehavior.AllowSort = false;
                settings.SettingsBehavior.AllowDragDrop = false;
                settings.SettingsBehavior.AllowSelectByRowClick = false;
                settings.SettingsLoadingPanel.Text = "数据读取中...";
                settings.SettingsBehavior.AllowClientEventsOnLoad = false;
                settings.SettingsBehavior.AllowFocusedRow = true;

                settings.Columns["se"].CellStyle.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Right;
                settings.Columns["FAdjustAmount"].CellStyle.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Right;
                settings.Columns["sumse"].CellStyle.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Right;

                settings.ClientSideEvents.BeginCallback = "function(s,e){OnBeginCallback(s,e)}";
                settings.CommandColumn.Visible = false;

                settings.PageIndexChanged = (sender, e) =>
                {
                    ASPxGridView grid = (ASPxGridView)sender;
                    grid.Selection.UnselectAll();
                };
                settings.DataBinding = (sender, e) =>
                {
                    ASPxGridView grid = (ASPxGridView)sender;
                    for (int i = 0; i < grid.AllColumns.Count; i++)
                    {
                        if (grid.AllColumns[i].CellStyle.HorizontalAlign == System.Web.UI.WebControls.HorizontalAlign.NotSet)
                        {
                            grid.AllColumns[i].CellStyle.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Center;
                        }
                        if (grid.AllColumns[i].HeaderStyle.HorizontalAlign == System.Web.UI.WebControls.HorizontalAlign.NotSet)
                        {
                            grid.AllColumns[i].HeaderStyle.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Center;
                        }
                    }
                };                                       
                
            }).Bind(Model).GetHtml()
